from PyQt5 import QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow
from ui.ui_mainwindow import Ui_MainWindow


class Ui_MainWindow_Ext(QMainWindow, Ui_MainWindow):

    def __init__(self, parent=None):
        super(Ui_MainWindow_Ext, self).__init__(parent)
        self.setupUi(self)
        # 连接 信号与槽
        self.setSingleSolt()

    def setSingleSolt(self):
        self.pbtnOpenImage.clicked.connect(self.openImageClick)
        self.actionExit.triggered.connect(self.doExit)
        # 打开图像并显示在label，注意

    def openImageClick(self):
        imgName, imgType = QtWidgets.QFileDialog.getOpenFileName(self.centralwidget, "打开图片", "",
                                                                 "*.bmp;;*.png;;All Files(*)")
        if imgName != "":
            jpg = QtGui.QPixmap(imgName).scaled(self.lblShowImage.width(), self.lblShowImage.height())
            self.lblShowImage.setPixmap(jpg)

        # 退出

    def doExit(self):
        self.centralwidget.parentWidget().close()
    # 加载
